package com.pet.server.ext.util;

public class NumberUtil {

	public static Integer getInteger(String val,Integer def){
		if(val!=null && !val.isEmpty()){
			 return Integer.valueOf(val);
		}
		return def;
	}
	public static Integer getInteger(String val){
		if(!StringUtil.isEmpty(val)){
			 return Integer.valueOf(val);
		}
		return null;
	}
	
	public static Double getDouble(String val){
		if(StringUtil.isEmpty(val)){
			return null;
		}else{
			return getDouble(val,null);
		}
		
	}
	public static Double getDouble(String val,Double def){
		try{
			return Double.parseDouble(val);
		}catch(Exception e){
			return def;
		}
		
	}
	public static Long getLong(String val,Long def){
		try{
			return Long.parseLong(val);
		}catch(Exception e){
			return def;
		}
		
	}
	public static Integer parseInteger(String val,Integer def){
		try{
			return Integer.parseInt(val);
		}catch(Exception e){
			return def;
		}
	}
}
